<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Confirm Order_{$webname}</title>
<meta name="keywords"    content="{$keywords}">
<meta name="description" content="{$description}">
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/reset.css" />
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/common.css" />
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome.min.css" />
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Plugins/FontAwesome/css/font-awesome-ie7.min.css" />
<![endif]-->
<!--公共样式结束-->
<!--页面样式开始-->
<link href="__PUBLIC__/Plugins/Validform/css/validform.css" rel="stylesheet" />
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/Css/page_confirm.css" />

<!--页面样式结束-->
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/Js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="{$NOW_THEME_URL}/Assets/Js/jquery.SuperSlide.2.1.1.js"></script>
<script src="__PUBLIC__/Plugins/Datepicker/WdatePicker.js"></script>
<style>
.invoice_title{
	border:1px solid #CCCCCC;
	height:20px;
	width:180px;
}
.dishestime{
	background:#FF6666;
	color:#FFF;
	padding:3px 10px;
}
</style>
</head>

<body>
<div class="zhezhao"></div>
<div class="mask"></div>
	<div class="zz">
	<!--top start-->
	<include file="Public:header" lang="true" />
	<!--top end-->
	
	<!--content start-->
	<div class="content">
		<div class="buzou clearfix">
			<div class="buzou_left clearfix">
				<dl>
					<dt>1.Select a location</dt>
					<dd><a href="{:U('Index/address')}"></a></dd>
				</dl>
				<dl>
					<dt>2.Restaurant</dt>
					<dd><a href="{:U('Restaurant/index')}"></a></dd>
				</dl>
				<dl>
					<dt>3.Choose dishes</dt>
					<dd><a href="{:U('Dishes/index')}&id={$outlet.id}"></a></dd>
				</dl>
				<dl class="hover">
					<dt>4.Confirm Order</dt>
					<dd><a href="#"></a></dd>
				</dl>
				<dl>
					<dt>5.Complete order</dt>
					<dd></dd>
				</dl>
			</div>
			<div class="buzou_right">
				<a href="http://vipwebchat.tq.cn/pageinfo.jsp?version=vip&admiuin=9632675&ltype=100&iscallback=0&page_templete_id=79615&is_message_sms=0&is_send_mail=0&action=acd&acd=1&type_code=1" target=_blank><img src="http://float2006.tq.cn/staticimg.jsp?version=vip&admiuin=9632675&ltype=100&action=acd&acd=1&type_code=1&onlinepic=http://userfiles.tq.cn/userfiles/upload_163/9632675/1411565972.png&offlinepic=http://userfiles.tq.cn/userfiles/upload_163/9632675/1411628431.png" border='0' /></a>
			</div>
		</div>
		<eq name="status" value="1">
			<div class="com_tips">Tips: You are our honored customer, please order directly. </div>
		<else />
			<div class="com_tips">Tips: Call <em class="com_tips tels">{$telphone}</em> to confirm!</div>
		</eq>
		
		<div class="confirm clearfix">
		<form action="{:U('Order/confirm')}" method="post" class="formTable addressForm" >
		<input type="hidden" name="is_exempt" value="{$outlet.is_exempt}" />
		<input type="hidden" name="outid" id="outid" value="{$outlet.id}" />
			<h1 class="color_main">Confirm Order<em>(Please check your order)</em></h1>
			<div class="address_window">
            <input type="hidden" name="addressid"  value="{$query.addid}">
            <input type="hidden" name="longitude"  value="{$query.pointlng}">
            <input type="hidden" name="latitude"   value="{$query.pointlat}">
            <input type="hidden" name="city"       value="{$query.cityid}">
            <input type="hidden" name='memaddress' value='{$memaddress.id}'>
            
            <php>if($memaddress['id']){</php>
            <div class="outside" flag="1">
                <span class="outside_tit"><b>Delivery To：</b> </span>
                <span><i class="icon-caret-right"></i>&nbsp;[{$memaddress.realname}&nbsp;{$memaddress.mobile}]&nbsp;{$query['adds']}</span>
            </div>
            <php>}</php>
            
            <table id="add_form" border="0" cellpadding="0" cellspacing="0" class="add_position" <notempty name='memaddress.id'>style='display:none'</notempty>>                
                <tr class="yanz">
                	<th>&nbsp;</th>
                    <td><div class="" id="Validform_errortip_div"></div></td>
                </tr>
                <tr>
                    <th>Name：</th>
                    <td>
                        <input type="text" id="realname" name="realname" placeholder="Please enter your name" datatype="*"
                        nullmsg="Please enter your name" errormsg="Please enter your name" value="{$memaddress.realname}">
                    </td>
                </tr>
                <empty name="memaddress.id">
	                <tr>
	                    <th>Password：</th>
	                    <td>
	                        <input type="password" id="password" name="password" placeholder="Please enter password" datatype="*6-18" 
	                        nullmsg="Please enter password" errormsg="The password may not be less than six figures">（As you registered kkrabbit member password）
	                    </td>
	                </tr>
                <tr>
                    <th>Email：</th>
                    <td>
                        <input type="text" id="email" name="email" placeholder="Please enter your email" datatype="e" 
                        nullmsg="Please enter your email" errormsg="Email input format is not correct">（eg：xyz@163.com，As a login kkrabbit account）
                    </td>
                </tr>
                </empty>
                <tr>
                    <th>Mobile：</th>
                    <td>
                        <input type="text" id="mobile" name="mobile" placeholder="Please enter your mobile" datatype="*11-12" 
                        nullmsg="Please enter your mobile" errormsg="Contact phone number input format is not correct" value="{$memaddress.mobile}">（eg：18588889999/01066668888，Please enter your mobile）
                    </td>
                </tr>
                <tr>
                    <th>Address：</th>
                    <td>
                    	<empty name="memaddress.id">
                    		<input type="text" id="adds" name="ads" readonly value="{$query.enadds}">
                    	<else />
                    		<input type="text" id="adds" name="ads" readonly value="{$memaddress.ads}">
                    	</empty>
                    </td>
                </tr>
                <tr>
                    <th>Detail：</th>
                    <td>
                    	<input type="text" id="detail" name="detail" placeholder="Please add your detailed address" datatype="*" 
                        nullmsg="Please add your detailed address" errormsg="Please add your detailed address" value="{$memaddress.detail}">（Please add your detailed address）
                    </td>
                </tr>			
            </table>
            </div>
			<div class="confirm1"></div>
			<div class="confirm2">
				<!--<h2 class="color_main">Restaurant of your choice：Avocado Tree</h2>-->
					<table width="100%" border="0" cellpadding="0" cellspacing="0">
						<tr>
							<th class="name">Gourmet menu</th>
							<th>Attribute</th>
							<th>Unit price</th>
							<th>Quantity</th>
							<th>Subtotal</th>
							<th>Edit</th>
						</tr>
						<tbody id="cartlist">
							<volist name="cart.list" id="k" key="vo" >
								<tr>
									<td align="left" class="name">
										{$k.entitle}
										<p><input type="text" placeholder="Remarks" cartid="{$k.id}"  class="nameinput asks"/></p>
										<div class="cnote-bubble group" id="n_p">
											<volist name="taste" id="vo" key="v" >
												<a class="cnote-item c_n_i" id="ask" cartid="{$k.id}">{$vo.en-us}</a>
											</volist>
										</div>
									</td>
									<td>
										<notempty name="k.attr">
											<volist name="k.attr" id="m">
												<span class="entitle">{$m.entitle|stripcslashes=###}：</span>
												<volist name="m.config" id="n">
													<span>{$n.entitle|stripcslashes=###}<notempty name='n.num'>（{$n.num}portion）</notempty></span>　
												</volist>
												<br/>
											</volist>
										</notempty>
									</td>
									<td align="center" id="dprice">￥{$k.price}</td>
									<td align="center" id="td">
										<div class="number">
											<ul class="count">
												<li data-id="{$k.id}" price="{$k.price}" class="minus" >-</li>
												<li id="num{$k.id}" class="num">{$k.num}</li>
												<li data-id="{$k.id}" price="{$k.price}" class="plus">+</li>
												
											</ul>
										</div>
									</td>
									<td align="center" class="dprice">￥<span id="xjprice">{$k.xjprice}</span></td>
									<td align="center"><i class="icon-remove color_main remove" rel="{$k.id}"></i></td>
								</tr>
							</volist>
						</tbody>
						<tr>
							<td class="total" colspan="6" align="right">Dliveryfee：￥
								<span id="dliveryfee">{$dliveryfee|number_format=2}</span>
								<input type="hidden" id="shipfee" name="shipfee" value="{:session('dliveryfee')}">
							</td>
						</tr>
						<tr>
							<td class="total" colspan="6" align="right">
								Total：￥<span class="totalprice">{$totalprice|number_format=2}</span>
								<input type="hidden" name="foodfee" class="foodfee" value="{$totalprice-$dliveryfee}">
							</td>
						</tr>
						<tr>
							<td class="back" colspan="6" align="right">
								<span style="font-size:18px;">Need drinks?</span>
								<a href="{:U('Dishes/index','id='.$outlet['id'])}">Back to Restaurant</a>
							</td>
						</tr>
					</table>
			</div>
			<div class="confirm3">
				<h2 class="color_main">Order Remarks</h2>
				<p><textarea name="content" cols="" rows="" placeholder="Note that you can fill your order for this special request orders here">{$member.remark}</textarea></p>
			</div>
			<div class="confirm4">
				<h2 class="color_main">Delivery time</h2>
				<h3>
					<eq name="outlet.yuding" value="2">
						<p><input type="radio" name="time"  value="{$dliverytime}" id="now" checked/>From now on&nbsp;&nbsp;&nbsp;&nbsp;
						About {$dliverytime} minutes</p>
						<php>if($cart['time']>0){</php>
							<span class="dishestime">{$cart.entitle} need {$cart.time} minutes</span>
						<php>}</php>	
						<input type="hidden" name="dishestime" value="{$cart.time}">
					</eq>
					<p>
						<input type="radio" name="time"   value="-1" id="book" />Reservation
						<input type="text"  name="ydtime"  id="ydtime"  style="display:none;" onfocus="WdatePicker({lang:'en',minDate:'%y-%M-{%d}'})" class="Wdate">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="text"  name="sdltime" id="sdltime" style="display:none;" onfocus="WdatePicker({lang:'en',skin:'whyGreen',dateFmt:'H:mm',minDate:'11:00',maxDate:'22:30'})" class="Wdate" />
					   - <input type="text" name="edltime" id="edltime" style="display:none;" onfocus="WdatePicker({lang:'en',skin:'whyGreen',dateFmt:'H:mm',minDate:'11:00',maxDate:'22:30'})" class="Wdate" />
						 <input type="hidden" name="yuding" value="{$outlet.yuding}">
					</p>
				</h3>
			</div>
			<div class="confirm6">
				<eq name='outlet.is_tigong' value='1'>
					<span><input name="isinvoice" type="checkbox" value="1" />Need invoice?</span>
					<input type="text" name="invoice_title" id="invoice_title" class="invoice_title" placeholder="Invoice title" style="display:none"></span>
				<else />
					<span><input name="isinvoice" type="checkbox" disabled/>Restaurant does not provide invoices</span>
				</eq>	
				<!--<span><input name="isprint"   type="checkbox" value="1" />Need print?</span>-->
				<span><input name="isconfirm" id="isconfirm" type="checkbox" value="1"/>Need customer service call to confirm?</span>
			</div>
			<div id="freeDrink" class="confirm6" <php>if(($totalprice-$dliveryfee)<50)echo "style='display:none'"</php>>Free Soft Drinks：
				<eq name="isdrink" value="1">
					<volist name="sdrink" id="vo" >
						<span><input name="isdrink" type="radio" value="{$key}" <eq name="key" value="0">checked</eq>/>{$vo.en-us}</span>
					</volist>
				</eq>
			</div>
			<div class="confirm5">
				<i class=" icon-volume-down icon-2x"></i>
				In case of the following situations: ①the dish you choose sold out or cancelled by restaurant ②New price ,Our operator will make a telephone confirmation with you . K.K.RABBIT would follow the latest menu sent from the restaurants. Sorry for not being able to update the menu online
			</div>
			<div class="confirm5">
				<i class=" icon-volume-down icon-2x"></i>
				Delivery time for the individual order you placed in the peak time of ordering may be delayed  half an hour .Sorry for not being able to promise you the accuracy of arrival time
			</div>
			<div class="order">
				<a href="{:U('Dishes/index','id='.$outlet['id'])}" class="fh">Return</a>
				<input type="submit" id="submit" value="Submit" class="xd">
			</div>
			</form>
		</div>
	</div>
	<!--content end-->
	
	<!--footer start-->
	<include file="Public:footer" lang="true" />
	<!--footer end-->
	<!--online start-->
		
	<!--online end-->
	</div>
	<div class="cityck selectcity">
		<h1>You haven't select the correct address, click the button to choose the address</h1>
		<h3><a href="{:U('Index/index')}" class="ck">To choose the city</a></h3>
	</div>
	<!--没有选择需要电话确认窗口开始-->
     <div class="telck istelck" style="display:none;width:42%;left:30%">
        <h1>Need customer service call to confirm?</h1>
        <h3><a id="sure_tel" class="sure_tel" style="cursor:pointer">Need</a><a class="ck goback" style="cursor:pointer">Unwanted</a></h3>
		<h2 style="color:#ba2f29">（If you need cancel the oder,please call 400-020-1717 within three minutes）</h2>
     </div>	
    <!--没有选择需要电话确认窗口结束-->
<script src="__PUBLIC__/Plugins/Validform/validform.min.js" ></script>
<script type="text/javascript">
	$(function(){
		
		<notempty name="noneCity">
			$('.selectcity').show();
			$('.zhezhao').show();
		</notempty>
		
		var flag = true ;  //定义全局变量
		var msg  = "" ;    //定义全局变量
		$(".addressForm").Validform({tiptype:function(msg,o,cssctl){
			var objtip=$("#Validform_errortip_div");cssctl(objtip,o.type);objtip.text(msg);}
			,tipmsg:{
					tit:"Prompt information",
					w:"Please input the correct information！",
					r:"Through the verification of the information！",
					c:"Checking information…",
					s:"Please fill in the information！",
					v:"The filled information has not been verified, please try later…",
					p:"Data are presented…",
					err:"Wrong! To address or return data format is wrong！",
					abort:"Ajax operation was canceled！"
			},
			beforeSubmit:function(data){
				if($('.istelck').is(':hidden')){
					if(!$("#isconfirm").prop("checked")){
						$('.zhezhao').show();
						$('.istelck').show();
						return false;
					}
				}
			}
		});

		//确定需要电话确认
		$("body").on('click','.sure_tel',function(){
			$("#isconfirm").prop('checked',true);
			$('#submit').click();
		});
		
		//不需要电话确认
		$(".goback").on('click',function(){
			$('#submit').click();
		});
		
		$(".zhezhao").on('click',function(){
			$(this).hide();
			$('.telck').hide();
		});
		
		//点击展开	 
		$('.outside').on('click',function(){
			var flag = $(".outside").attr("flag")	
			if(flag==1){				
				$('#add_form').show();	
				$('.outside').attr("flag",2)
				$('.outside i').removeClass("icon-caret-right")
				$('.outside i').addClass("icon-caret-down")
			}else{
				$('#add_form').hide();	
				$('.outside').attr("flag",1)
				$('.outside i').removeClass("icon-caret-down")
				$('.outside i').addClass("icon-caret-right")
			}
		});
		
		//返回顶部
		$(window).on('scroll',function(){
			var scrollTop = $(document).scrollTop();
		});
		
		//修改地址弹出窗口
		$('.addaddress span').on('click',function(){
			$('.mask').show();
			$('.address_window').show();
		});
		$('.address_window .return').on('click',function(){
			$('.mask').hide();
			$('.address_window').hide();	
		});
		$('.address_window').css('left',($(window).width()-660)/2+'px');
		$('.mask').height($(document.body).height());
		
		$('.saveaddress').live('click',function(){
			$('.mask').show();
			$('.address_window').show();
			var realname  = $("#realname").val();
			var mobile    = $("#mobile").val();
			var enaddress = $("#enaddress").val();
			var address   = "{$query.enadds}"+enaddress;
			if(realname==""){
				$("#Validform_errortip_div").html("Please enter your name");return false;
			}
			if(mobile==""){
				$("#Validform_errortip_div").html("Please enter your phone");return false;
			} 
			if(enaddress==""){
				$("#Validform_errortip_div").html("Please enter your address");return false;
			}
			
			postData = $("#addressaddform").serialize();
			$.post("{:U('Public/add_address')}",postData,function(d){
				if(d.status==1){
					var id = "{$Think.get.id}";
					window.location.href="{:U('Order/confirm')}&id="+id;
				}else{
					alert('Address add fail!');return;
				}
			})
		});
		
		//修改地址窗口结束
		$("input[name='isinvoice']").on('click',function(){
			if($(this).prop('checked')){
				$('.invoice_title').show();
			}else{
				$('.invoice_title').hide();
			}
		});
		
		//默认地址高亮显示
		$("input[name='addressid']").on('click',function(){
			if($(this).prop("checked")){
				var lng = $(this).parents('tr').attr('longitude');
				var lat = $(this).parents('tr').attr('latitude');
				getDliveryfee(lng,lat);
			}	
		});
		
		var yuding = "{$outlet.yuding}";
		if(yuding==1){
			$("#sdltime").show();
			$("#edltime").show();
			$("#ydtime").show();
			$("#ydtime").val("{:date('Y-m-d')}");
			$("input[name='time']").prop("checked",true);
		}
		
		//点击显示配送时间
		$("#book").on("click",function(){
			$("#sdltime").show();
			$("#edltime").show();
			$("#ydtime").show();
		});
		//点击隐藏配送时间
		$("#now").on("click",function(){
			$("#sdltime").hide();
			$("#edltime").hide();
			$("#ydtime").hide();
		});
		
		//地址删除
		$('.href').on('click',function(){
			var id = $(this).attr("rel"); 
			$.post("{:U('Member/address_index')}",{id:id});
		});
		
		//悬浮框显示隐藏
		$('.online').on('hover',function(){
			$('.online ul').toggle();
			//$('.rlico').toggleClass('rlico2');
		});
		
		//菜品口味
		$('.cnote-bubble a').on('click',function(){
			var neirong = $(this).html();
			var ask     = $(this).html();
			var cartid  = $(this).attr("cartid");
			var obj = $(this).parent().siblings().children('input');
			$(this).parent().siblings().children('input').val(neirong);
			askedit(ask,cartid);
		}); 
		//菜品口味
		$(".asks").each(function(){
			$(this).on("change",function(){
				var ask    = $(this).val();
				var cartid = $(this).attr("cartid");
				askedit(ask,cartid);
			});
		});
		
		$('.zz').on('click',function(){
			$(".cnote-bubble").hide();
		});
		
		/*
		$(".nameinput").on('click',function(){
			$(this).parents("p").siblings(".cnote-bubble").show();
			return false;
		});
		*/
		//隔行换色
		$('.confirm1 table tr:odd').addClass('odd');
		$('.confirm1 table tr:even').addClass('even');
		
		//隔行换色
		$('.online ul li:odd').addClass('odd');
		$('.online ul li:even').addClass('even');
		
		
		//删除购物车中的一件商品
		$('.remove').live('click',function(){
			
			$(this).parent('td').parent('tr').remove();	
			var id = $(this).attr("rel");
			delone(id);
			changetotal();
		});
		
		//减少商品数量
		$('.minus').on("click",function(){
			var obj    = $(this).siblings('li.num');
			var price  = parseInt($(this).attr("price"));
			var num    = parseInt(obj.html());
			var id     = $(this).attr("data-id");
			if(num==1){
				return false;
			}else{
				num -= 1;
				obj.html(num);
				price = price*num ;
				price = price.toFixed(2);
				$(this).parent('.count').parent('.number').parent('#td').siblings('.dprice').children('span').html(price);				
				changetotal();
				setnum(id,price,num);
			}
		});
		//增加商品价格
		$('.plus').on("click",function(){
			var obj     = $(this).siblings('li.num');
			var price  = parseInt($(this).attr("price"));//alert(price1)
			var num    = parseInt(obj.html());
			var id     = $(this).attr("data-id");
			if(num>=20){
				return false;
			}else{
				num += 1;
				obj.html(num);
				price = price*num ;
				price = price.toFixed(2);
				$(this).parent('.count').parent('.number').parent('#td').siblings('.dprice').children('span').html(price);
				setnum(id,price,num);
				changetotal();
			}
		});
		
		$('.addtable tr td input').click(function(){
			if($(this).filter(':checked')){
				$('.addtable tr').css({background:'',color:'#333'})
				$(this).parent('td').parent('tr').css({background:'#FE6736',color:'#fff'});	
				if($(this).val() == -1){
					$('.confirm .confirm1 .c1table').show();
					$(".addressForm").addClass("formTable");
				}else{
					$('.confirm .confirm1 .c1table').hide();
					$(".addressForm").removeClass("formTable");
				}
			}	
		})
		
	});
function askedit(ask,cartid){
	$.get("{:U('Order/editask')}",{cartid:cartid,ask:ask});
}
//计算价格
function changetotal(){
	
	var total      = 0;   //商品总价含运送费	
	var foodfee    = 0;   //商品总价格不含运送费
	var dliveryfee = "{$dliveryfee}";  //运送费
	var outletid   = "{$outlet.id}";
	$.get("{:U('Dishes/calculateTotal')}",{outletid:outletid},function(d){
		
		if(d.status==1){
			foodfee = parseInt(d.data);
			total   = foodfee + parseInt(dliveryfee);
			total   = total.toFixed(2);
			foodfee = foodfee.toFixed(2);
			
			if(foodfee>=50){
				$('#freeDrink').show();
			}else{
				$('#freeDrink').hide();
			}

			$(".foodfee").val(foodfee)
			$(".totalprice").html(total);
		}
	});
}
//异步删除购物车中的商品
function delone(id){
	$.get("{:U('Dishes/delone')}",{id:id},function(html){
		$('.spc_ul').html(html);
		changetotal(); //计算总价
	});
}
//修改购物车中菜品的数量
function setnum(id,price,num){
	var postData    = {};
	postData.id     = id;
	postData.num    = num;
	postData.price  = price;
	$.post("{:U('Dishes/setnum')}",postData);
}

	//修改地址弹出窗口
	$('.addaddress span').on('click',function(){
		$('.mask').show();
		$('.address_window').show();
	});
	$('.address_window .aw_btn').on('click',function(){
		$('.mask').hide();
		$('.address_window').hide();	
	});
	$('.address_window').css('left',($(window).width()-740)/2+'px');
	$('.mask').height($(document.body).height());

	function getDliveryfee(lng,lat){
		var c_lng = "{$outlet.longitude}";
		var c_lat = "{$outlet.latitude}";
		var outletid = $('#outid').val();
		
		$.get("{:U('Order/getDliveryfee')}",{c_lng:c_lng,c_lat:c_lat,y_lng:lng,y_lat:lat,outletid:outletid},function(data){
			if(data.status){
				
				var totalprice = parseInt($('.totalprice').html());
				
				dliveryfee = data.dliveryfee;
				totalprice = totalprice+dliveryfee;
				
				dliveryfee = dliveryfee.toFixed(2);
				totalprice = totalprice.toFixed(2);
				$('#dliveryfee').html(dliveryfee);
				$('#shipfee').val(dliveryfee);
				$('.totalprice').html(totalprice);
			}else{
				alert(data.info);
			}
		},'json');
	}
</script>
</body>
</html>
